﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;
using GPCSC.Web;
using System.Data;

namespace GPCSC.Web.AJAX
{
    /// <summary>
    /// countAjax 的摘要说明
    /// </summary>
    public class countAjax : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Write("Hello World");
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
        #region IHttpHandler 成员

        bool IHttpHandler.IsReusable
        {
            get { throw new NotImplementedException(); }
        }
        /// <summary>
        /// 保存活动
        /// </summary>
        /// <param name="context"></param>
        void IHttpHandler.ProcessRequest(HttpContext context)
        {
            try
            {
                string hdid = context.Request["hdid"].ToString();
                string lgid = context.Request["lgid"].ToString();
                string type = context.Request["type"].ToString();
                Hashtable htable = new Hashtable();
                htable.Add("@hdid",hdid);
                htable.Add("@lgid",lgid);

                DataSet ds = new DataSet();
                string strru = "";
               
                DataSet dss = new DataSet();
                dss = new SqlReadXml().ReaderDataSet("couall", htable);
                if (dss != null)
                {
                    if (dss.Tables.Count > 0)
                    {
                        if (dss.Tables[0].Rows.Count > 0)
                        {
                            foreach (DataRow dr in dss.Tables[0].Rows)
                            {
                                strru += dr["couall"].ToString() + "?";
                            }
                        }
                    }
                }
                switch (type)
                {
                    case "1":
                        if (hdid != "" && hdid != "")
                        {
                            ds = new SqlReadXml().ReaderDataSet("sel_NongCun_byid", htable);
                            if (ds.Tables.Count > 0)
                            {
                                if (ds.Tables[0].Rows.Count > 0)
                                {
                                    //foreach (DataRow dr in ds.Tables[0].Rows)
                                    //{ 

                                    //}
                                    if (ds.Tables[0].Rows[0]["NCIsTJ"].ToString() == "0")
                                    {
                                        ds.Tables[0].Rows[0]["title"] = "未提交";
                                    }
                                    else
                                    {
                                        ds.Tables[0].Rows[0]["title"] = "已提交";
                                    }
                                    //context.Response.ContentType = "text/plain";
                                    //context.Response.Write(ds.Tables[0].Rows[0]["title"].ToString());
                                    strru += ds.Tables[0].Rows[0]["title"].ToString() + "?";
                                }
                            }
                        }
                        break;

                    case "2":
                        if (hdid != "" && hdid != "")
                        {
                            ds = new SqlReadXml().ReaderDataSet("sel_SheQu_byid", htable);
                            if (ds.Tables.Count > 0)
                            {
                                if (ds.Tables[0].Rows.Count > 0)
                                {
                                    //foreach (DataRow dr in ds.Tables[0].Rows)
                                    //{ 

                                    //}
                                    if (ds.Tables[0].Rows[0]["SQIsTJ"].ToString() == "0")
                                    {
                                        ds.Tables[0].Rows[0]["title"] = "未提交";
                                    }
                                    else
                                    {
                                        ds.Tables[0].Rows[0]["title"] = "已提交";
                                    }
                                    strru += ds.Tables[0].Rows[0]["title"].ToString() + "?";
                                }
                            }
                        }
                        break;
                    case "3":
                        if (hdid != "" && hdid != "")
                        {
                            ds = new SqlReadXml().ReaderDataSet("sel_QiYe_byid", htable);
                            if (ds.Tables.Count > 0)
                            {
                                if (ds.Tables[0].Rows.Count > 0)
                                {
                                    //foreach (DataRow dr in ds.Tables[0].Rows)
                                    //{ 

                                    //}
                                    if (ds.Tables[0].Rows[0]["QYIsTJ"].ToString() == "0")
                                    {
                                        ds.Tables[0].Rows[0]["title"] = "未提交";
                                    }
                                    else
                                    {
                                        ds.Tables[0].Rows[0]["title"] = "已提交";
                                    }
                                    strru += ds.Tables[0].Rows[0]["title"].ToString() + "?";
                                }
                            }
                        }
                        break;
                }

                context.Response.ContentType = "text/plain";
                context.Response.Write(strru);
            }
            catch (Exception ee)
            {
                throw ee;
            }

        }

        #endregion
    }
}